:root {
  --primary-color: #1a73e8;
  --secondary-color: #f1f3f4;
  --text-color: #202124;
  --border-color: #dadce0;
  --success-color: #34a853;
  --error-color: #d93025;
  --warning-color: #f9ab00;
  --current-user-color: #1a73e8;
  --other-user-color: #34a853;
  --background-color: #f7f9fc;

  /* Dark mode variables */
  --dark-primary-color: #0b4796;
  --dark-secondary-color: #3a3c40;
  --dark-text-color: #e8eaed;
  --dark-border-color: #5f6368;
  --dark-background-color: #202124;
}

.dark-mode {
  --primary-color: var(--dark-primary-color);
  --secondary-color: var(--dark-secondary-color);
  --text-color: var(--dark-text-color);
  --border-color: var(--dark-border-color);
  --background-color: var(--dark-background-color);

  background-color: var(--dark-background-color);
  color: var(--dark-text-color);
}

* {
  transition: all 0.3s ease;
}

.dark-mode .chat-container {
  background-color: var(--dark-background-color);
  border-color: var(--dark-border-color);
}

.dark-mode .chat-header {
  background-color: var(--dark-primary-color);
  border-color: var(--dark-border-color);
}

.dark-mode .message {
  background-color: #2d2f33;
  color: var(--dark-text-color);
}

.dark-mode .current-user {
  background-color: #1e3a5f;
}

.dark-mode .other-user {
  background-color: #2d3e50;
}

.dark-mode .system-message {
  color: #9aa0a6;
}

.dark-mode .file-container {
  background-color: #2d2f33;
  border-color: var(--dark-border-color);
}

.dark-mode .file-link {
  color: var(--dark-text-color);
}

.dark-mode .file-size {
  color: #9aa0a6;
}

.dark-mode .progress-container {
  background-color: #2d2f33;
  border-color: var(--dark-border-color);
}

.dark-mode .progress-bar-container {
  background-color: #1e1e1e;
}

.dark-mode .modal-content {
  background-color: var(--dark-background-color);
  color: var(--dark-text-color);
}

.dark-mode .modal-content input,
.dark-mode .input-container input,
.dark-mode .input-container textarea {
  background-color: var(--dark-background-color);
  color: var(--dark-text-color);
  border-color: var(--dark-border-color);
}


* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', sans-serif;
  color: var(--text-color);
  background-color: var(--background-color);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.chat-container {
  width: 100%;
  max-width: 1200px;
  height: 90vh;
  background-color: var(--background-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--primary-color);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  position: relative;
}

.chat-header .desktop-title {
  margin-right: auto;
}

.chat-header .mobile-title {
  display: none;
}

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  color: white;
}

.theme-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-toggle::after {
  content: attr(title);
  position: absolute;
  top: 120%;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  white-space: nowrap;
}

.theme-toggle:hover::after {
  opacity: 1;
}

.theme-toggle svg {
  width: 24px;
  height: 24px;
  fill: white;
}

.moon-icon {
  display: none;
}

.dark-mode .moon-icon {
  display: block;
}

.dark-mode .sun-icon {
  display: none;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--warning-color);
}

.status-text {
  font-size: 0.9rem;
}

.chat-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.user-list {
  width: 200px;
  border-right: 1px solid var(--border-color);
  padding: 16px;
  overflow-y: auto;
}

.user-list h3 {
  margin-bottom: 12px;
}

.user-list ul {
  list-style: none;
}

.user-list li {
  padding: 4px 0;
}

.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 8px;
  background-color: var(--secondary-color);
}

.current-user {
  align-self: flex-end;
  background-color: #e8f0fe;
}

.current-user .message-header {
  color: var(--current-user-color);
}

.other-user {
  align-self: flex-start;
  background-color: #e6f4ea;
}

.other-user .message-header {
  color: var(--other-user-color);
}

.message-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #5f6368;
  margin-bottom: 4px;
}

.message-header span {
  margin: 0 4px;
}

.message-header span:first-child {
  margin-left: 0;
}

.message-header span:last-child {
  margin-right: 0;
}

.message-content {
  word-wrap: break-word;
  white-space: pre-wrap;
  transition: color 0.05s ease;
}

.system-message {
  align-self: center;
  font-size: 0.9rem;
  color: #5f6368;
  margin: 8px 0;
}

/* 图片消息样式 */
.image-container {
  max-width: 400px;
  margin: 8px 0;
}

.message-image {
  max-width: 100%;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.message-image:hover {
  transform: scale(1.02);
}

/* 文件消息样式 */
.file-container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
  padding-bottom: 12px;
  background-color: rgba(255, 255, 255, 0.8);
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.file-link {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.2s;
  word-break: break-all;
  white-space: normal;
  max-width: 200px;
  display: inline-block;
}

.file-link:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.file-size {
  color: #5f6368;
  font-size: 0.8rem;
}

/* 图片模态框样式 */
.image-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-image {
  max-width: 90%;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* 修改输入区域样式 */
.input-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background-color: var(--background-color);
  border-top: 1px solid var(--border-color);
}

/* 添加输入操作行样式 */
.input-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
}

/* 修改进度条容器样式 */
.progress-container {
  width: 100%;
  padding: 8px;
  background-color: var(--secondary-color);
  border-radius: 4px;
  margin-top: 4px;
  position: relative;
  display: none;
  border: 1px solid var(--border-color);
  opacity: 1;
  transition: opacity 0.3s ease;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text-color);
}

.progress-filename {
  font-weight: 500;
  margin-right: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

@media (max-width: 768px) {
  .progress-filename {
    white-space: normal;
    word-break: break-word;
    max-width: 100%;
  }
}

.progress-stats {
  white-space: nowrap;
  color: #5f6368;
}

.progress-bar-container {
  width: 100%;
  height: 4px;
  background-color: #e0e0e0;
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background-color: var(--primary-color);
  width: 0;
  transition: width 0.2s ease;
  border-radius: 2px;
}

.progress-text {
  position: absolute;
  right: 0;
  top: -18px;
  /* 显示在进度条上方 */
  font-size: 12px;
  color: var(--text-color);
}

/* 调整文本输入框样式 */
.input-container input {
  width: 0;
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  resize: none;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  margin: 0;
}

/* 调整按钮样式 */
.input-container button {
  padding: 8px 16px;
  height: 40px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

#sendBtn {
  background-color: var(--primary-color);
  color: white;
  min-width: 44px;
  padding: 8px;
}

/* 修改上传按钮样式 */
.upload-btn {
  background-color: var(--secondary-color);
  color: var(--text-color);
  min-width: 80px;
  transition: all 0.3s ease;
}

.upload-btn::before {
  display: none;
  content: "+";
  font-size: 24px;
  font-weight: bold;
}

#sendBtn:hover,
.upload-btn:hover {
  opacity: 0.9;
}

#confirmNickname {
  padding: 8px 16px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  transition: opacity 0.2s ease;
}

#confirmNickname:hover {
  opacity: 0.9;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal-content {
  background-color: white;
  padding: 24px;
  border-radius: 8px;
  width: 300px;
  text-align: center;
}

.modal-content input {
  width: 100%;
  padding: 8px;
  margin: 16px 0;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

@media (max-width: 768px) {
  .chat-container {
    height: 100vh;
    border-radius: 0;
  }

  .chat-header {
    display: flex;
    justify-content: flex-end;
  }

  .user-list,
  .chat-container .desktop-title {
    display: none;
  }

  .chat-container .mobile-title {
    display: block;
    margin-right: auto;
  }

  .image-container {
    max-width: 250px;
  }

  .upload-btn {
    min-width: 36px;
    width: 36px;
    padding: 0;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
  }

  .upload-btn span {
    display: none;
  }

  .upload-btn::before {
    display: block;
  }

  /* 调整输入区域布局 */
  .input-actions {
    position: relative;
    gap: 4px;
  }

  .input-actions {
    gap: 4px;
  }
}

/* 添加修改昵称按钮样式 */
.change-nickname-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  color: white;
}

.change-nickname-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
}

.change-nickname-btn:active {
  transform: scale(0.95);
}

.change-nickname-btn::after {
  content: attr(title);
  position: absolute;
  top: 120%;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  white-space: nowrap;
}

.change-nickname-btn:hover::after {
  opacity: 1;
}

/* 视频消息样式 */
.video-container {
  max-width: 320px;
  margin: 8px 0;
}

.video-preview {
  position: relative;
  width: 100%;
  height: 180px;
  background-color: #000;
  background-size: cover;
  background-position: center;
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-info {
  display: flex;
  flex-wrap: wrap;
}

.default-video-preview {
  background-color: #2d2f33;
}

.play-button {
  position: absolute;
  width: 48px;
  height: 48px;
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.play-button svg {
  width: 24px;
  height: 24px;
  color: white;
}

.video-preview:hover .play-button {
  transform: scale(1.1);
}

.video-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.video-modal video {
  max-width: 90%;
  max-height: 90vh;
}

/* 深色模式适配 */
.dark-mode .video-preview {
  background-color: #1e1e1e;
}

.dark-mode .play-button {
  background-color: rgba(255, 255, 255, 0.1);
}

/* 移动端适配 */
@media (max-width: 768px) {
  .video-container {
    max-width: 250px;
  }

  .video-preview {
    height: 140px;
  }

  .play-button {
    width: 40px;
    height: 40px;
  }

  .play-button svg {
    width: 20px;
    height: 20px;
  }
}